package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.Clazz;
import org.example.pojo.ClazzQueryParm;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Mapper
public interface ClazzMapper {
    /**
     * 根据id查询班级
     * @param id
     */
    @Select("select * from clazz where id = #{id}")
    public Clazz findById(Integer id) ;

    /**
     * 查询班级总数
     */
    @Select("select count(*) from clazz")
   public Long count();
    /**
     * 分页查询(查询所有）
     */
    public List<Clazz> findAll(ClazzQueryParm parm);
    /**
     * 根据id删除
     */
    @Delete("delete  from clazz where id = #{id}")
    public void deleteById(Integer id);

    /**
     * 保存班级
     * @param clazz
     */
    @Insert("insert into clazz(name, room, begin_date, end_date, master_id, subject, create_time, update_time)" +
            " VALUE (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void save(Clazz clazz);

    /**
     * 修改班级
     * @param clazz
     */
    @Update("update clazz set name = #{name}, room = #{room}, begin_date = #{beginDate}, end_date = #{endDate}, master_id = #{masterId}, subject = #{subject}, update_time = #{updateTime} where id = #{id}")
    void update(Clazz clazz);
}
